package tech.aistar.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;

/**
 * 本类用来演示: 可以监听HttpSession对象的状态的改变[属性值的改变]
 *
 * @author: success
 * @date: 2021/4/19 9:00 上午
 */
@WebListener
public class SessionAttrListenerAction implements HttpSessionAttributeListener {
    /**
     * 只要每次向session作用域中添加数据的时候
     * @param event
     */
    @Override
    public void attributeAdded(HttpSessionBindingEvent event) {
        System.out.println("add...");
    }

    /**
     * 调用session.removeAttribute
     * @param event
     */
    @Override
    public void attributeRemoved(HttpSessionBindingEvent event) {
        System.out.println("remove..");
    }
}
